/***************************************************************************
    begin                : Wed Jan 29 2003
    copyright            : (C) 2003 - 2014 by Alper Akcan
    email                : alper.akcan@gmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is dual licensed free software; you can redistribute     * 
 *   it and/or modify it under the terms of the GNU Lesser General Public  *
 *   License, as published by the Free Software Foundation (version 2.1 or * 
 *   later) OR alternatively under the terms of BSD (3-clause) license.    *
 *                                                                         *
 ***************************************************************************/

#define KEYCODE_KEYS	128
#define KEYCODE_PLAIN	0
#define KEYCODE_SHIFT	1
#define KEYCODE_ALTGR	2
#define KEYCODE_FLAGS	3

#define NUM_VGAKEYMAPS	(1 << KG_CAPSSHIFT)
static unsigned short s_video_helper_keybd_keymap[NUM_VGAKEYMAPS][NR_KEYS];

static s_keyboard_button_t s_video_helper_keybd_keycode_[KEYCODE_KEYS][KEYCODE_FLAGS] = {
/*  keycode,     plain name,            shift name,      	altgr name */
/*   0 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*   1 */ 	{KEYBOARD_BUTTON_ESCAPE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*   2 */ 	{KEYBOARD_BUTTON_ONE,		KEYBOARD_BUTTON_EXCLAM,	KEYBOARD_BUTTON_NOCODE},
/*   3 */ 	{KEYBOARD_BUTTON_TWO,		KEYBOARD_BUTTON_AT,		KEYBOARD_BUTTON_AT},
/*   4 */ 	{KEYBOARD_BUTTON_THREE,	KEYBOARD_BUTTON_NUMBERSIGN,	KEYBOARD_BUTTON_NOCODE},
/*   5 */ 	{KEYBOARD_BUTTON_FOUR,	KEYBOARD_BUTTON_DOLLAR,	KEYBOARD_BUTTON_DOLLAR},
/*   6 */	{KEYBOARD_BUTTON_FIVE,	KEYBOARD_BUTTON_PERCENT,	KEYBOARD_BUTTON_CURRENCY},
/*   7 */ 	{KEYBOARD_BUTTON_SIX,		KEYBOARD_BUTTON_ASCIICIRCUM,	KEYBOARD_BUTTON_NOCODE},
/*   8 */ 	{KEYBOARD_BUTTON_SEVEN,	KEYBOARD_BUTTON_AMPERSAND,	KEYBOARD_BUTTON_BRACELEFT},
/*   9 */ 	{KEYBOARD_BUTTON_EIGHT,	KEYBOARD_BUTTON_ASTERISK,	KEYBOARD_BUTTON_BRACKETLEFT},
/*  10 */ 	{KEYBOARD_BUTTON_NINE,	KEYBOARD_BUTTON_PARENLEFT,	KEYBOARD_BUTTON_BRACKETRIGHT},
/*  11 */ 	{KEYBOARD_BUTTON_ZERO,	KEYBOARD_BUTTON_PARENRIGHT,	KEYBOARD_BUTTON_BRACERIGHT},
/*  12 */ 	{KEYBOARD_BUTTON_MINUS,	KEYBOARD_BUTTON_UNDERSCORE,	KEYBOARD_BUTTON_BACKSLASH},
/*  13 */ 	{KEYBOARD_BUTTON_EQUAL,	KEYBOARD_BUTTON_PLUS,		KEYBOARD_BUTTON_NOCODE},
/*  14 */ 	{KEYBOARD_BUTTON_DELETE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  15 */ 	{KEYBOARD_BUTTON_TAB,		KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  16 */ 	{KEYBOARD_BUTTON_q,		KEYBOARD_BUTTON_Q,		KEYBOARD_BUTTON_NOCODE},
/*  17 */ 	{KEYBOARD_BUTTON_w,		KEYBOARD_BUTTON_W,		KEYBOARD_BUTTON_NOCODE},
/*  18 */ 	{KEYBOARD_BUTTON_e,		KEYBOARD_BUTTON_E,		KEYBOARD_BUTTON_NOCODE},
/*  19 */ 	{KEYBOARD_BUTTON_r,		KEYBOARD_BUTTON_R,		KEYBOARD_BUTTON_NOCODE},
/*  20 */ 	{KEYBOARD_BUTTON_t,		KEYBOARD_BUTTON_T,		KEYBOARD_BUTTON_NOCODE},
/*  21 */ 	{KEYBOARD_BUTTON_y,		KEYBOARD_BUTTON_Y,		KEYBOARD_BUTTON_NOCODE},
/*  22 */ 	{KEYBOARD_BUTTON_u,		KEYBOARD_BUTTON_U,		KEYBOARD_BUTTON_NOCODE},
/*  23 */ 	{KEYBOARD_BUTTON_i,		KEYBOARD_BUTTON_I,		KEYBOARD_BUTTON_NOCODE},
/*  24 */ 	{KEYBOARD_BUTTON_o,		KEYBOARD_BUTTON_O,		KEYBOARD_BUTTON_NOCODE},
/*  25 */ 	{KEYBOARD_BUTTON_p,		KEYBOARD_BUTTON_P,		KEYBOARD_BUTTON_NOCODE},
/*  26 */	{KEYBOARD_BUTTON_BRACKETLEFT,	KEYBOARD_BUTTON_BRACELEFT,	KEYBOARD_BUTTON_NOCODE},
/*  27 */ 	{KEYBOARD_BUTTON_BRACKETRIGHT,KEYBOARD_BUTTON_BRACERIGHT,	KEYBOARD_BUTTON_ASCIITILDE},
/*  28 */ 	{KEYBOARD_BUTTON_RETURN,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  29 */ 	{KEYBOARD_BUTTON_LEFTCONTROL,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  30 */ 	{KEYBOARD_BUTTON_a,		KEYBOARD_BUTTON_A,		KEYBOARD_BUTTON_NOCODE},
/*  31 */	{KEYBOARD_BUTTON_s,		KEYBOARD_BUTTON_S,		KEYBOARD_BUTTON_NOCODE},
/*  32 */ 	{KEYBOARD_BUTTON_d,		KEYBOARD_BUTTON_D,		KEYBOARD_BUTTON_NOCODE},
/*  33 */	{KEYBOARD_BUTTON_f,		KEYBOARD_BUTTON_F,		KEYBOARD_BUTTON_NOCODE},
/*  34 */ 	{KEYBOARD_BUTTON_g,		KEYBOARD_BUTTON_G,		KEYBOARD_BUTTON_NOCODE},
/*  35 */ 	{KEYBOARD_BUTTON_h,		KEYBOARD_BUTTON_H,		KEYBOARD_BUTTON_NOCODE},
/*  36 */ 	{KEYBOARD_BUTTON_j,		KEYBOARD_BUTTON_J,		KEYBOARD_BUTTON_NOCODE},
/*  37 */ 	{KEYBOARD_BUTTON_k,		KEYBOARD_BUTTON_K,		KEYBOARD_BUTTON_NOCODE},
/*  38 */ 	{KEYBOARD_BUTTON_l,		KEYBOARD_BUTTON_L,		KEYBOARD_BUTTON_NOCODE},
/*  39 */ 	{KEYBOARD_BUTTON_SEMICOLON,	KEYBOARD_BUTTON_COLON,	KEYBOARD_BUTTON_NOCODE},
/*  40 */ 	{KEYBOARD_BUTTON_APOSTROPHE,	KEYBOARD_BUTTON_QUOTEDBL,	KEYBOARD_BUTTON_NOCODE},
/*  41 */ 	{KEYBOARD_BUTTON_GRAVE,	KEYBOARD_BUTTON_ASCIITILDE,	KEYBOARD_BUTTON_NOCODE},
/*  42 */ 	{KEYBOARD_BUTTON_LEFTSHIFT,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  43 */ 	{KEYBOARD_BUTTON_BACKSLASH,	KEYBOARD_BUTTON_BAR,		KEYBOARD_BUTTON_NOCODE},
/*  44 */ 	{KEYBOARD_BUTTON_z,		KEYBOARD_BUTTON_Z,		KEYBOARD_BUTTON_NOCODE},
/*  45 */	{KEYBOARD_BUTTON_x,		KEYBOARD_BUTTON_X,		KEYBOARD_BUTTON_NOCODE},
/*  46 */ 	{KEYBOARD_BUTTON_c,		KEYBOARD_BUTTON_C,		KEYBOARD_BUTTON_CENT},
/*  47 */ 	{KEYBOARD_BUTTON_v,		KEYBOARD_BUTTON_V,		KEYBOARD_BUTTON_NOCODE},
/*  48 */ 	{KEYBOARD_BUTTON_b,		KEYBOARD_BUTTON_B,		KEYBOARD_BUTTON_NOCODE},
/*  49 */ 	{KEYBOARD_BUTTON_n,		KEYBOARD_BUTTON_N,		KEYBOARD_BUTTON_NOCODE},
/*  50 */ 	{KEYBOARD_BUTTON_m,		KEYBOARD_BUTTON_M,		KEYBOARD_BUTTON_NOCODE},
/*  51 */ 	{KEYBOARD_BUTTON_COMMA,	KEYBOARD_BUTTON_LESS,		KEYBOARD_BUTTON_NOCODE},
/*  52 */ 	{KEYBOARD_BUTTON_PERIOD,	KEYBOARD_BUTTON_GREATER,	KEYBOARD_BUTTON_NOCODE},
/*  53 */ 	{KEYBOARD_BUTTON_SLASH,	KEYBOARD_BUTTON_QUESTION,	KEYBOARD_BUTTON_NOCODE},
/*  54 */ 	{KEYBOARD_BUTTON_RIGHTSHIFT,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  55 */ 	{KEYBOARD_BUTTON_KP_MULTIPLY,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_HEX_C},
/*  56 */ 	{KEYBOARD_BUTTON_ALT,		KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  57 */ 	{KEYBOARD_BUTTON_SPACE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  58 */ 	{KEYBOARD_BUTTON_CAPS_LOCK,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  59 */ 	{KEYBOARD_BUTTON_F1,		KEYBOARD_BUTTON_F13,		KEYBOARD_BUTTON_NOCODE},
/*  60 */ 	{KEYBOARD_BUTTON_F2,		KEYBOARD_BUTTON_F14,		KEYBOARD_BUTTON_NOCODE},
/*  61 */ 	{KEYBOARD_BUTTON_F3,		KEYBOARD_BUTTON_F15,		KEYBOARD_BUTTON_NOCODE},
/*  62 */ 	{KEYBOARD_BUTTON_F4,		KEYBOARD_BUTTON_F16,		KEYBOARD_BUTTON_NOCODE},
/*  63 */ 	{KEYBOARD_BUTTON_F5,		KEYBOARD_BUTTON_F17,		KEYBOARD_BUTTON_NOCODE},
/*  64 */ 	{KEYBOARD_BUTTON_F6,		KEYBOARD_BUTTON_F18,		KEYBOARD_BUTTON_NOCODE},
/*  65 */ 	{KEYBOARD_BUTTON_F7,		KEYBOARD_BUTTON_F19,		KEYBOARD_BUTTON_NOCODE},
/*  66 */ 	{KEYBOARD_BUTTON_F8,		KEYBOARD_BUTTON_F20,		KEYBOARD_BUTTON_NOCODE},
/*  67 */ 	{KEYBOARD_BUTTON_F9,		KEYBOARD_BUTTON_F21,		KEYBOARD_BUTTON_NOCODE},
/*  68 */ 	{KEYBOARD_BUTTON_F10,		KEYBOARD_BUTTON_F22,		KEYBOARD_BUTTON_NOCODE},
/*  69 */ 	{KEYBOARD_BUTTON_NUM_LOCK,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_HEX_A},
/*  70 */ 	{KEYBOARD_BUTTON_SCROLL_LOCK,	KEYBOARD_BUTTON_SHOW_MEMORY,	KEYBOARD_BUTTON_SHOW_REGISTERS},
/*  71 */ 	{KEYBOARD_BUTTON_KP_7,	KEYBOARD_BUTTON_HOME,		KEYBOARD_BUTTON_HEX_7},
/*  72 */ 	{KEYBOARD_BUTTON_KP_8,	KEYBOARD_BUTTON_UP,		KEYBOARD_BUTTON_HEX_8},
/*  73 */ 	{KEYBOARD_BUTTON_KP_9,	KEYBOARD_BUTTON_PAGEUP,	KEYBOARD_BUTTON_HEX_9},
/*  74 */ 	{KEYBOARD_BUTTON_KP_SUBTRACT,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_HEX_D},
/*  75 */ 	{KEYBOARD_BUTTON_KP_4,	KEYBOARD_BUTTON_LEFT,		KEYBOARD_BUTTON_HEX_4},
/*  76 */	{KEYBOARD_BUTTON_KP_5,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_HEX_5},
/*  77 */	{KEYBOARD_BUTTON_KP_6,	KEYBOARD_BUTTON_RIGHT,	KEYBOARD_BUTTON_HEX_6},
/*  78 */	{KEYBOARD_BUTTON_KP_ADD,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_HEX_E},
/*  79 */ 	{KEYBOARD_BUTTON_KP_1,	KEYBOARD_BUTTON_END,		KEYBOARD_BUTTON_HEX_1},
/*  80 */ 	{KEYBOARD_BUTTON_KP_2,	KEYBOARD_BUTTON_DOWN,		KEYBOARD_BUTTON_HEX_2},
/*  81 */ 	{KEYBOARD_BUTTON_KP_3,	KEYBOARD_BUTTON_PAGEDOWN,	KEYBOARD_BUTTON_HEX_3},
/*  82 */ 	{KEYBOARD_BUTTON_KP_0,	KEYBOARD_BUTTON_INSERT,	KEYBOARD_BUTTON_HEX_0},
/*  83 */ 	{KEYBOARD_BUTTON_KP_PERIOD,	KEYBOARD_BUTTON_REMOVE,	KEYBOARD_BUTTON_NOCODE},
/*  84 */	{KEYBOARD_BUTTON_LAST_CONSOLE,KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  85 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  86 */	{KEYBOARD_BUTTON_LESS,	KEYBOARD_BUTTON_GREATER,	KEYBOARD_BUTTON_BAR},
/*  87 */ 	{KEYBOARD_BUTTON_F11,		KEYBOARD_BUTTON_F23,		KEYBOARD_BUTTON_NOCODE},
/*  88 */ 	{KEYBOARD_BUTTON_F12,		KEYBOARD_BUTTON_F24,		KEYBOARD_BUTTON_NOCODE},
/*  89 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  90 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  91 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  92 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  93 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  94 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  95 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  96 */ 	{KEYBOARD_BUTTON_KP_ENTER,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_HEX_F},
/*  97 */ 	{KEYBOARD_BUTTON_RIGHTCONTROL,KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/*  98 */ 	{KEYBOARD_BUTTON_KP_DIVIDE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_HEX_B},
/*  99 */ 	{KEYBOARD_BUTTON_VOIDSYMBOL,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 100 */ 	{KEYBOARD_BUTTON_ALTGR,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 101 */ 	{KEYBOARD_BUTTON_BREAK,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 102 */ 	{KEYBOARD_BUTTON_HOME,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 103 */ 	{KEYBOARD_BUTTON_UP,		KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 104 */	{KEYBOARD_BUTTON_PAGEUP,	KEYBOARD_BUTTON_SCROLL_BACKWARD,	KEYBOARD_BUTTON_NOCODE},
/* 105 */	{KEYBOARD_BUTTON_LEFT,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 106 */	{KEYBOARD_BUTTON_RIGHT,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 107 */	{KEYBOARD_BUTTON_END,		KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 108 */	{KEYBOARD_BUTTON_DOWN,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 109 */	{KEYBOARD_BUTTON_PAGEDOWN,	KEYBOARD_BUTTON_SCROLL_FORWARD,	KEYBOARD_BUTTON_NOCODE},
/* 110 */	{KEYBOARD_BUTTON_INSERT,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 111 */	{KEYBOARD_BUTTON_REMOVE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 112 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 113 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 114 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 115 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 116 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 117 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 118 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 119 */ 	{KEYBOARD_BUTTON_PAUSE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 120 */ 	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 121 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 122 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 123 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 124 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 125 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 126 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
/* 127 */	{KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE,	KEYBOARD_BUTTON_NOCODE},
};
